﻿Imports System.Data
Imports System.Data.Odbc
Imports System.Text
Imports System.Collections.Generic
Imports WSEntidades
Imports Utilerias
Imports WSFactory
Imports MySql.Data.MySqlClient

Public Class ProcesosDAL
    Private cadConex As String = ""

    Public Sub New(ByVal pCadConex As String)
        Me.cadConex = pCadConex
    End Sub

#Region "FuncionesUtilizables"

    Public Function getListadoProcesos() As List(Of ProcesosBE)
        Dim ProcesosLs As List(Of ProcesosBE) = New List(Of ProcesosBE)
        Try
            Using myConn As MySqlConnection = New MySqlConnection(Me.cadConex)
                Using myComm As MySqlCommand = myConn.CreateCommand()
                    myComm.CommandText = "SELECT idproceso, proceso " & _
                                           "FROM procesos;"
                    myComm.CommandType = CommandType.Text
                    myConn.Open()
                    Using myDR As MySqlDataReader = myComm.ExecuteReader()
                        While myDR.Read()
                            Dim Proceso As ProcesosBE = ProcesosFact.Build(myDR)
                            If (Not Proceso Is Nothing) Then
                                ProcesosLs.Add(Proceso)
                            End If
                            Proceso = Nothing
                        End While
                    End Using
                End Using
            End Using
            Return ProcesosLs
        Catch ex As Exception
            Throw
        Finally
            ProcesosLs = Nothing
        End Try
    End Function

#End Region

End Class
